Skip to content

Conversation

@dweindl
Copy link
Member

@dweindl dweindl commented Nov 18, 2025

During model import, simplify piecewise functions that can be expressed as min()/max().

So far, all piecewise constructs are treated as discontinuous (see also #2049). For min/max, only the derivative is discontinuous, which currently does not receive any special treatment in amici (see also https://amici.readthedocs.io/en/latest/implementation_discontinuities.html).

So this change prevents root tracking for some unnecessary piecewises. Addresses some aspects of #2049.

@dweindl dweindl self-assigned this Nov 18, 2025
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.47%. Comparing base (8fc33dc) to head (2f96fa0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3053      +/-   ##
==========================================
- Coverage   78.14%   77.47%   -0.68%     
==========================================
  Files         311      311              
  Lines       20593    20602       +9     
  Branches     1499     1499              
==========================================
- Hits        16092    15961     -131     
- Misses       4491     4631     +140     
  Partials       10       10              
Flag Coverage Δ
cpp 70.74% <100.00%> (-0.02%) ⬇️
cpp_python 37.17% <44.44%> (+<0.01%) ⬆️
petab 45.83% <77.77%> (+0.01%) ⬆️
petab_sciml 13.80% <22.22%> (+<0.01%) ⬆️
python 69.40% <100.00%> (-0.02%) ⬇️
sbmlsuite-jax ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
python/sdist/amici/importers/sbml/__init__.py 82.52% <100.00%> (-11.94%) ⬇️
python/sdist/amici/sympy_utils.py 78.57% <100.00%> (+2.76%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl dweindl marked this pull request as ready for review November 18, 2025 10:57
@dweindl dweindl requested a review from a team as a code owner November 18, 2025 10:57
# piecewise to heavisides
if piecewise_to_heaviside:
try:
expr = expr.replace(sp.Piecewise, _piecewise_to_minmax)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add small test with actual model to make sure that we are not reverting this substitution someplace else?

During model import, simplify piecewise functions that can be expressed as min()/max().

So far, all piecewise constructs are treated as discontinuous (see also AMICI-dev#2049).
For min/max, only the derivative is discontinuous, which currently does not receive any
special treatment in amici (see also https://amici.readthedocs.io/en/latest/implementation_discontinuities.html).

So this change prevents root tracking for some unnecessary piecewises.
Addresses some aspects of AMICI-dev#2049.
@dweindl dweindl enabled auto-merge November 18, 2025 15:43
@dweindl dweindl added this pull request to the merge queue Nov 18, 2025
Merged via the queue into AMICI-dev:main with commit c84db32 Nov 18, 2025
38 of 60 checks passed
@dweindl dweindl deleted the piecewise_minmax branch November 18, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants